<?php
require 'include/library.inc.php';
	
if ($_POST['is_submitted']) {
	$error_message = '';
	
	if (!$_POST['name'])	$error_message .= 1;
	if (!$_POST['email'])	$error_message .= 2;
	elseif (!checkEmail($_POST['email']))
	$error_message .= 2;
	
	if (!$_POST['message'])	$error_message .= 3;
		
	if (!$error_message) {
	
		$name = escape($_POST['name']);
		$email = escape($_POST['email']);
		$message = $_POST['message'];
		
		# Mail to Admin
	    mail( ADMINISTRATOR_EMAIL,
	          CONTACT_FORM_SUBJECT, 
	          sprintf(CONTACT_FORM_MESSAGE, $name, $email, $message), 
	          HTML_HEADERS."From: ".$name." <".$email.">");
		
		$_SESSION['message'] = 'Message successfully sent! Thank you!';
		redirect ("contacts.php");
		
	}
}


head("Contact ESL Traveler","We help you with course selection, visas, housing, travel arrangement and airport pickup!",100);
?>
	
    <?php if ($_SESSION['message']) { ?>
	<script type="text/javascript">
    $(function(){$('div.message').delay(3000).slideUp('slow');});
    </script>
    <div class="message green">
        <?=$_SESSION['message']?>
    </div>
    <?php unset($_SESSION['message']); } ?>
    
    	<div id="left">
        	<h2>Contact ESL Traveler</h2>
            
            <div class="padding">
				
		
            <form class="contacts" action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
            <input type="hidden" name="is_submitted" value="1" />
            
                
                Your Name:<br/>
                <input class="inputbox w500 <?=((preg_match('#[1]#',$error_message))?"redborder":"")?>" name="name" type="text" value="<?=$_POST['name']?>" maxlength="50" /><br/>
                
                Email Address:<br/>
                <input class="inputbox w500 <?=((preg_match('#[2]#',$error_message))?"redborder":"")?>" name="email" type="text" value="<?=$_POST['email']?>" maxlength="50" /><br/>
                			
                
                Message:<br/>
                <textarea class="inputbox w500 <?=((preg_match('#[3]#',$error_message))?"redborder":"")?>" name="message" style="height:160px;"><?=$_POST['message']?></textarea>
                <br/><br/>
                
                <button type="submit" class="button" name="button" >Send</button>
                
                
                <br /><br />
                
                </form>
            
            </div>
        </div>
        
        <div class="right">
            <h2>Contacts</h2>
            
            <div class="padding">
                <b>Tel.</b> +1 718 710 0498<br>
                <b>Fax.</b> +1 866 935 5127<br>
                <b>Email:</b> info@esltraveler.com<br>
                
                <b>Address:</b>
                111 E Mosholu parkway suite 3 F<br>
                New York City, NY 10467
            </div>
        </div>
        
        <div class="right">
        	<h2>Map</h2>
            
            <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
			<script type="text/javascript" src="<?=HTML_BASE?>js/map.js"></script>
            
            <div id="map" style="width:100%; height:250px;">
            	<script type="text/javascript">
					initialize("40.877959","-73.882188");
				</script>
            </div>
        </div>
        
            
<?php foot(); ?>